<!--
 * @Description: 
 * @Author: zhuying
 * @Date: 2024-11-14 11:19:57
 * @LastEditors: rendc
 * @LastEditTime: 2024-11-14 17:01:27
-->
<template>
  
  <div class="bg">

    
    <!-- <button>按钮</button>
    <el-button>按钮</el-button> -->
    <!-- 注册组件 -->
    <!-- <Reg v-if="flag" @my-alert="myAlert" /> -->
    <!-- 登录 -->
    <!-- <login v-if="!flag" />
    <p v-if="flag" @click="changeFlag">已有账号，直接<a href="">登录</a></p>
    <p v-if="!flag" @click="changeFlag">没有账号，立即<a href="">注册</a></p>
    
    <button @click="changeFlag">{{ flag ? '去登录页面' : '去注册页面' }}</button> -->
    <!-- 按钮的样式 -->
    <!-- type、plain、round 和 circle -->
    <!-- 写一个主要按钮 -->
    <!-- <el-button type="primary" :disabled="flag" plain round>主要按钮</el-button>
    <el-button type="primary" :loading="loading" @click="toLogin">登录</el-button>
    <br> -->
    <!-- <el-checkbox v-model="checked1" label="Option 1" size="large" />
    <el-checkbox v-model="checked2" label="Option 2" size="large" disabled /> -->
    <!-- <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="date" label="日期" width="180" />
      <el-table-column prop="name" label="名字" width="180" />
      <el-table-column prop="address" label="地址" />
      <el-table-column fixed="right" label="Operations" min-width="120">
        <template #default="scope">
          <el-button link type="primary" size="small" @click="handleClick(scope.row)">
            Detail
          </el-button>
          <el-button link type="primary" size="small" >Edit</el-button>
          <el-button size="small" @click="handleClicks2(scope.row)" link type="danger">Delete</el-button>
          -->
          
          <div style="font-size: 30px; text-align: center;" id="tb1">课程表</div>
        <el-table :data="StudentIf" border style="width: 100%">
           <el-table-column prop="date" label="学号" width="180" />
           <el-table-column prop="name" label="姓名" width="180" />
           <el-table-column prop="score" label="分数" />
           <el-table-column prop="speak" label="评语" />
      
           <el-table-column fixed="right" label="Operations" min-width="120">
             <template #default="scope">
               <el-button link type="primary" size="small" @click="handleClick(scope.row)">
                 Detail
               </el-button>
               <el-button link type="primary" size="small" >Edit</el-button>
               <el-button size="small" @click="handleClicks3(scope.row)" link type="danger">Delete</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>



<script setup>
import { ref } from 'vue';
import Reg from './components/views/Reg.vue';
import Login from './components/views/Login.vue';
// flag 为 true 显示注册页面
// flag 为 false 显示登录页面
const flag = ref(true);
const loading = ref(false);
const checked1 = ref(true);
const checked2 = ref(true);
const StudentIf=ref([
  {
    date:'001',
    name: '张三',
    score: 90,
    speak: '很优秀'
  },
  {
    date: '002',
    name: '李四',
    score: 92,
    speak: '优秀'
  },
  {
    date: '003',
    name: '王五',
    score: 83,
    speak:'很努力,不错'
  },
  {
    date: '004',
    name: '赵六',
    score: 98,
    speak:'666'

},
])
// const tableData = ref([
//   {
//     date: '2016-05-03',
//     name: 'Tom',
//     address: 'No. 189, Grove St, Los Angeles',
//   },
//   {
//     date: '2016-05-02',
//     name: 'Tom',
//     address: 'No. 189, Grove St, Los Angeles',
//   },
// ]);

// 切换登录注册页面
function changeFlag () {
  flag.value = !flag.value;
}
// 父组件中声明的事件
function myAlert () {
  alert('我是父组件中的事件-myAlert');
}
// 登录
function toLogin () {
  loading.value = true;
  // 模拟登录请求
  setTimeout(() => {
    alert('登录成功');
    loading.value = false;
  }, 3000);
}
const handleClick = (row) => {
  console.log('🚀 - handleClick - row:', row);
  console.log('🚀 - handleClick - row.name:', row.name);

}
const handleClicks3 = (row) => {
  
  // 找到要删除行数据在 tableData 数组中的索引
  const index = StudentIf.value.findIndex(item => item === row);
 if (index!== -1) {
     // 根据索引删除该行数据
     StudentIf.value.splice(index, 1);
 }}
 const handleClicks2 = (row) => {
  
  // 找到要删除行数据在 tableData 数组中的索引
  const index = tableData.value.findIndex(item => item === row);
 if (index!== -1) {
     // 根据索引删除该行数据
     tableData.value.splice(index, 1);
 }}
 
 
</script>
<style scoped>
.bg {
  /* background-image: url(./xxx.png); */
}
.el-button {
  background-color: rgb(237, 187, 222);
}
</style>